<?php
class Like_model extends CI_Model {

	public $userId;
	public $productId;
	
	public function hasLiked($userId, $productId)	{
		$this->db->where('userId', $userId);
		$this->db->where('productId', $productId);
		$query = $this->db->get('likes', 1, 0)->result();
		return (!empty($query));
	}
	
	public function add($userId, $productId)	{
		$this->userId = $userId;
		$this->productId = $productId;
		$this->db->insert('likes', $this);
	}
	
	public function remove($userId, $productId)	{
		$this->db->where('userId', $userId);
		$this->db->where('productId', $productId);
		$this->db->delete('likes');
	}
}
?>